<template>
  <div class="payRecBox">
    <mt-search
      class="search"
      v-model="queryInfo.searchInfo"
      placeholder="输入关键字查询">
    </mt-search>

    <mt-loadmore :bottom-method="loadBottom" :bottom-all-loaded="allLoaded" ref="loadmore">
      <ul class="item">
        <li>
          <div @click="goDetails('recId')">
            <div class="payRecords">
              <div>
              <span class="name">张素素&nbsp;<span class="sef">(本人)</span></span>
              <span class="pay">已缴费</span>
              </div>
              <div>
              <span class="data">2020-06-15 15:00</span>
              <span class="iconfont iconarrow-right arrow"></span>
              </div>
              <div>
              <span class="address">厦门市思明区龙虎路726号501</span>
              <span class="amount">3200</span>
              </div>
            </div>
          </div>
          <div class="footer">
            <span class="tuikuan">退款</span>
            <span class="Invoice">开票</span>
          </div>
        </li>
      </ul>
    </mt-loadmore>
  </div>
</template>

<script>
export default {
  data () {
    return {
      // 用户当前的支付状态 已缴费(1) 已退款(2)
      paySatus: 1,
      // 数据是否全部加载判断 标志位
      allLoaded: false,
      // 总页数
      totalPage: 10,
      // 查询参数
      queryInfo: {
        // 搜索关键字
        searchInfo: '',
        // 当前页
        start: 1,
        // 每行显示几条
        rows: 4
      }
    }
  },
  created () {
    this.getPaylog()
  },
  methods: {
    // 获取缴费记录
    async getPaylog () {
      const payLog = await this.$http.get('list/payLog', { params: this.queryInfo })
      console.log(payLog)
    },
    // 进入单条缴费记录的详情页面
    goDetails (id) {
      // 判断用户当前的支付状态
      if (this.paySatus !== 1) {
        this.$router.push('/refundDetails?id=' + id)
        return
      }
      this.$router.push('/paymentDetails?id=' + id)
    },
    // 下拉加载更多数据
    loadBottom () {
      if (this.totalPage === this.queryInfo.start) {
        this.allLoaded = true // 若数据已全部获取完毕 loadBottom不会再被执行
      }
      //  ... 加载更多数据
      console.log('more')
      // 当前页 + 1
      this.queryInfo.start = this.queryInfo.start + 1

      this.$refs.loadmore.onBottomLoaded()
    }
  }

}
</script>

<style lang="less" scoped>
  .payRecBox {
    box-sizing: border-box;
    border: 1px solid transparent;
    padding-left: 20px;
    padding-top: 54px;
    padding-right: 20px;
    .item {
      list-style: none;
      padding: 0;
      margin: 0;
    }
    .search {
      border: 1px solid #ccc;
      border-radius: 3px;
    }
    /deep/ .mint-search {
      height: 34px;
    }
    /deep/ .mint-searchbar {
      padding: 0;
      background-color: #fff;
    }
    /deep/ .mint-searchbar-inner {
      padding: 0;
      height: 34px;
      // border: 2px solid #ccc;
      // border-radius: 5px;
    }
    /deep/ i {
      font-size: 22px;
      color: #9A9A9A;
      margin: 0 8px 0 6px;
    }
    /deep/ a {
      height: 34px;
      line-height: 34px;
      padding: 0 10px;
      color: #333333;
      // border: 1px solid #ccc;
      // border-radius: 5px;
    }
    /deep/ input::-webkit-input-placeholder {
      font-size: 15px;
      color: #CCCCD1;
    }
    /deep/ input {
      color: #666666;
      font-size: 15px;
    }
  }
  .search {
    margin-bottom: 25px;
  }

  .payRecords {
    margin-bottom: 10px;
  }
  .payRecords > div {
    display: flex;
    justify-content: space-between;
  }
  .payRecords div:nth-child(1) {
    font-size: 15px;
    margin-bottom: 10px;
    padding-right: 30px;
  }
  .payRecords div:nth-child(3) {
    padding-right: 43px;
  }
  .payRecords div:nth-child(4) {
    justify-content: flex-end;
    margin-top: 10px;
  }
  .footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 15px;
  }
  .footer span {
    box-sizing: border-box;
    padding: 3px 15px;
  }
  .name {
    color: #333333;
    font-weight: 500;
  }
  .sef {
    color: #999999;
  }
  .pay {
    color: #008000;
  }
  .data {
    font-size: 13px;
    color: #999;
  }
  .arrow {
    font-size: 22px;
    font-weight: 600;
    color: #C1D1D1;
  }
  .address {
    font-size: 14px;
    color: #666666;
  }
  .amount {
    font-size: 14px;
  }
  .tuikuan {
    border: 1px solid #488CEE;
    border-radius: 5px;
    color: #488CEE;
    margin-right: 15px;
  }
  .Invoice {
    border: 1px solid #F59E0E;
    border-radius: 5px;
    color: #F59E0E;
  }

</style>
